package com.tx.dao;

import com.tx.entity.Manager;
import com.tx.util.JdbcUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class ManagerDao {
    QueryRunner qr = JdbcUtil.getQr();
    public Manager login(String username,String password) throws SQLException {
        Manager manager = null;
        String sql = "select*from tb_manager where username=? and password=? ";
        manager = qr.query(sql,new BeanHandler<>(Manager.class),username,password);
        return manager;
    }
    public int regist(String username,String password){
        int rows = 0;
        String sql = "insert into tb_manager(username,password) value(?,?)";
        try {
            rows=qr.update(sql,username,password);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return rows;
    }

}
